create table p2 (
	product_id int auto_increment not null,
    name varchar(50) not null,
    quantity_in_stock decimal(6, 2) not null,
    unit_price decimal(6, 2) not null,
    primary key(product_id)
) engine=InnoDB;

-- 把产品表中的所有数据插入到p1表中
insert into p1 (
	name,
    quantity_in_stock,
    unit_price)
select
	name,
    quantity_in_stock,
    unit_price
from products;

select * from p1;

begin;

insert into p1 (
	name,
    quantity_in_stock,
    unit_price)
select
	name,
    quantity_in_stock,
    unit_price
from
	products
where
	product_id <= 5;
    
insert into p2 (
	name,
    quantity_in_stock,
    unit_price)
select
	name,
    quantity_in_stock,
    unit_price
from
	products
where
	product_id > 5;

rollback;

-- 采购 20

-- 当前库存 30

-- 当前销售 10

